package commands;

import factory.CentralFactory;
import ihm.ApplicationPanel;
import model.subject.Sensor;

/**
 * Implémentation de l'interface Command, destinée à modifier la stratégie utilisée pour la diffusion des valeurs du capteur.
 */
public class NotifyStrategyChangesToSensorCommandImpl implements Command {

	private ApplicationPanel applicationPanel;	// Invoker de la commande
	private Sensor sensor;						// Receiver de la commande
	
	private CentralFactory factory;
	
	public NotifyStrategyChangesToSensorCommandImpl(ApplicationPanel applicationPanel, Sensor sensor, CentralFactory factory) {
		this.applicationPanel = applicationPanel;
		this.sensor = sensor;
		
		this.factory = factory;
	}
	
	@Override
	public void execute() {
		sensor.setSpreadingAlgorithme(factory.createSpreadingAlgorithme(applicationPanel.getCurrentStrategyNumber()));
	}
	
}
